#include "battle.h"

//技能检定
int Skill_Check(herodata* hero1, herodata* hero2, int skill1, int skill2, int choose1, int choose2,int player_len)
{
	if (hero1->MP != 3)
	{
		hero1->MP++;
	}
	if (hero1->MP >= 2 && hero1->HP > 0 && hero2->HP > 0)
	{
		if (skill1 == 2 && hero1->Stun == 0 && choose1 != 4)
		{
			printf("'%s'对'%s'使用十星炮\n", hero1->name, hero2->name);
			hero1->MP -= 2;
			if (((skill2==2 && hero2->MP>=2)||(skill2==3 && player_len<=1 && hero2->MP>=2)||(skill2==2 && hero2->MP>=2) || (skill2==4 && player_len<=2 && hero2->MP>=3)) && hero2->Stun==0)
			{
				return 1;
			}
			if (choose2 != 4 || hero2->Stun != 0)
			{
				hero2->HP -= 30;
				printf("造成了'%d'伤害,'%s'剩余'%d'HP\n", 30, hero2->name, hero2->HP);
			}
			return 1;
		}
		if (skill1 == 3 && hero1->Stun == 0 && choose1 != 4 && player_len <= 1)
		{
			printf("'%s'对'%s'使用升龙斩\n", hero1->name, hero2->name);
			hero1->MP-=2;
			if (skill2==4 && player_len<=2 && hero2->Stun==0)
			{
				return 1;
			}
			if (choose2 != 4 || hero2->Stun != 0)
			{
				hero2->HP -= 40;
				printf("造成了'%d'伤害,'%s'剩余'%d'HP\n", 40, hero2->name, hero2->HP);
			}
			if (choose2 == 4 && hero2->Stun == 0)
			{
				hero1->Stun = 2;
			}
			return 1;
		}
	}
	if (hero1->MP == 3 && hero1->HP > 0 && hero2->HP > 0)
	{
		if (hero1->Stun==0 && skill1==4 && choose1!=4 && player_len<=2)
		{
			printf("\n");
			printf("############################\n");
			printf("要上了'%s'!!!\n", hero2->name);
			printf("'%s'对'%s'使用十天极\n", hero1->name, hero2->name);
			printf("############################\n");
			hero1->MP -= 3;
			if (skill2==4 && hero2->MP==3 && hero2->Stun==0)
			{
				return 1;
			}
			if (choose2 != 4 || hero2->Stun != 0)
			{
				hero2->HP -= 80;
				printf("造成了'%d'伤害,'%s'剩余'%d'HP\n", 80, hero2->name, hero2->HP);
			}
			if (choose2 == 4 && hero2->Stun == 0)
			{
				hero1->Stun = 1;
			}
			return 1;
		}

	}
	
	return 0;
}